package com.atguigu.flink.datastreamapi.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * Created by Smexy on 2023/4/3
 *
 *  用于测试
 */
public class Demo1_TestSource
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        //基于元素构造数据源  非并行运行的source
       // DataStreamSource<Integer> ds = env.fromElements(1, 2, 3, 4, 5);

        //基于Collection构造数据源 非并行运行的source
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        DataStreamSource<Integer> ds = env.fromCollection(list);

        ds.print();


        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
